<?php
/**
 * 
 * @author Freezy
 *
 */
class Login extends MY_Controller {
	function Login(){
		parent::MY_Controller ();
	}

	function _check(){
		$this->load->model('login_model');
		$usrname = $this->input->post('username');
		$password = $this->input->post('password');
		
		$res = $this->login_model->authenticate($usrname, $password);
		
		if ($res) ;
		
		echo json_encode(array('error'=>!$res,
			'msg'=>$res? "" : "Kombinasi Username dan Password salah",

			//FIXME : betulkan nanti, checking menu navigasi dan level user
			'url'=>$res? $this->_initialize_page($usrname) : ""));
	}
	
	function _initialize_page($usrname){
		$this->load->library('session');
		$this->session->set_userdata('logged', true);
		$this->session->set_userdata('usrname', $usrname);
		
		if (strtolower($usrname) == "admin"){
			return site_url(array('psdm','dashboard'));
		}
		return "";
	}
}
/* End of file auth.php */
/* Location: ./system/application/controllers/auth.php */